import {
    CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, ModuleWithProviders, SkipSelf,
    Optional
} from "@angular/core";
import {CommonModule, LocationStrategy} from "@angular/common";
import {QueryAndHashLocationStrategy} from "./providers/query.and.hash.location.strategy";
import {BarPageComponent} from "./components/bar-page/bar.page.component";
import {ImageUrlPipe} from "./pipes/image.url";
import {MyPhonePipe} from "./pipes/phone.pipe";
import {MyDataPipe} from "./pipes/datetime.pipe";
import {ToTopComponent} from "./components/to-top/to.top.component";
import {DefaultBarPageConfig} from "./providers/bar.page.config";
import {BarPageConfig} from "./domains/domains";
import {NavBarComponent} from "./components/navBar/navBar.component";
import {NumSliderComponent} from "./components/num-slider/num.slider.component";
import {MenuPanelComponent} from "./components/menu-panel/menu.panel.component";
import {PasswordPageComponent} from "./components/password-page/password.page.component";
import {DfModalService} from "./providers/df.modal.service";
import {GeolocationsService} from "./providers/geolocations.service";
import {HttpClientModule} from "@angular/common/http";
import {ImageSelectorComponent} from "./components/image-selector/image.selector.component";
import {NavigationWheelComponent} from "./components/navigation-wheel/navigation.wheel.component";
import {SelectionBarComponent} from "./components/selection.bar.component";
import {FormsModule} from "@angular/forms";
import {ImageEditorComponent} from "./components/images-editor/image.editor.component";
@NgModule({
    declarations:[
        BarPageComponent,ToTopComponent,NavBarComponent,NumSliderComponent,
        MenuPanelComponent,PasswordPageComponent,ImageSelectorComponent,ImageEditorComponent,
        NavigationWheelComponent,SelectionBarComponent,
        ImageUrlPipe,MyPhonePipe,MyDataPipe
    ],
    exports:[
        BarPageComponent,ToTopComponent,NavBarComponent,NumSliderComponent,
        MenuPanelComponent,PasswordPageComponent,ImageSelectorComponent,ImageEditorComponent,
        NavigationWheelComponent,SelectionBarComponent,
        ImageUrlPipe,MyPhonePipe,MyDataPipe
    ],
    imports:[CommonModule,HttpClientModule,FormsModule],
    schemas:[
        CUSTOM_ELEMENTS_SCHEMA,
        NO_ERRORS_SCHEMA
    ]
})
export class DFCommonModule{
    static forRoot(config: any): ModuleWithProviders {
        return config?{
            ngModule: DFCommonModule,
            providers: [
                DfModalService,GeolocationsService,
                {provide:LocationStrategy,useClass:QueryAndHashLocationStrategy},
                {provide: BarPageConfig, useClass: config }
            ]
        }:{
            ngModule: DFCommonModule,
            providers: [
                DfModalService,GeolocationsService,
                {provide:LocationStrategy,useClass:QueryAndHashLocationStrategy},
                {provide: BarPageConfig, useClass: DefaultBarPageConfig }
            ]
        };
    }
}